/*
* pps-cloud
*/
package com.pitop.cycle.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

import com.pitop.cycle.api.CycleTimeFeignApi;
import com.pitop.core.exceptions.CycleTimeException;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.entity.Page;
import com.pitop.cycle.entity.CycleTime;


/**
 * 生产周期
 * @author berton
 */
@Service("cycleTimeSVImpl")
@Slf4j
public class CycleTimeSVImpl {

    @Autowired
    private CycleTimeFeignApi cycleTimeFeignApi;

    /**
     * 加载一个对象CycleTime
     * @param id id* @param code 编码
     * @return CycleTime
     */
    public CycleTime load(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new CycleTimeException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return cycleTimeFeignApi.load(id,code);
    }
    /**
     * 加载一个对象CycleTime 通过id
     * @param id id
     * @return CycleTime
     */
    public CycleTime loadById(java.lang.Long id) {
        if(id==null){
            throw new CycleTimeException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return cycleTimeFeignApi.loadById(id);
    }

    /**
     * 加载一个对象CycleTime 通过code
     * @param code 编码
     * @return CycleTime
     */
    public CycleTime loadByCode(java.lang.String code) {
        if(code==null){
            throw new CycleTimeException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return cycleTimeFeignApi.loadByCode(code);
    }


    /**
     * 删除对象CycleTime
     * @param id id* @param code 编码
     * @return CycleTime
     */
    
    public void delete(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new CycleTimeException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        cycleTimeFeignApi.delete(id,code);
    }



    /**
     * 查询CycleTime分页
     *
     * @param cycleTime  对象
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<CycleTime>
     */
    public List<CycleTime> list(CycleTime cycleTime, int curPage,int pageSize) {
        return cycleTimeFeignApi.list(cycleTime, curPage,pageSize);
    }

    /**
     * 查询CycleTime分页
     *
     * @param id  id* @param code  编码
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<CycleTime>
     */
    public List<CycleTime> list(java.lang.Long id,java.lang.String code,int curPage, int pageSize) {
        if (curPage < 0) {
           curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        CycleTime cycleTime=new CycleTime();
        cycleTime.setId(id);
        cycleTime.setCode(code);

        return cycleTimeFeignApi.list(cycleTime,curPage,pageSize);
    }


    public int count(java.lang.Long id,java.lang.String code) {
        return cycleTimeFeignApi.count(id,code);
    }


    public int count(CycleTime cycleTime) {
        return cycleTimeFeignApi.count(cycleTime);
    }


    /**
     * 保存
     *
     * @param cycleTime 实体
     * @throws BaseException
     */
    public void save(CycleTime cycleTime) {
        if(cycleTime==null){ throw new CycleTimeException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        cycleTimeFeignApi.build(cycleTime);
    }

    /**
     * 更新
     *
     * @param cycleTime 实体
     * @throws BaseException
     */
    public void modify(CycleTime cycleTime) {
        if(cycleTime==null){ throw new CycleTimeException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        cycleTimeFeignApi.modify(cycleTime);
    }

}
